package main

import (
	"github.com/tarm/serial"
	"net"
	"time"
)

type SerialTrans struct {
	SourceConn *net.Conn
	Value      []byte
	serial.Config
}

func (s *SerialTrans) GetSourceConn() net.Conn {
	return *s.SourceConn
}

func (s *SerialTrans) GetTargetPort() (*serial.Port, error) {
	if s.Config.ReadTimeout > 200*time.Microsecond {
		s.Config.ReadTimeout = 200 * time.Microsecond
	}
	return serial.OpenPort(&s.Config)
}
